import Moment from 'moment';

const DEFINE_BASIC_VALUES = {
  today: [
    Moment({ hour: 0, minute: 0, seconds: 0 }).format('yyyy-M-D H:m:s'),
    Moment({ hour: 23, minute: 59, seconds: 59 }).format('yyyy-M-D H:m:s'),
  ],
  yesterday: [
    Moment({ hour: 0, minute: 0, seconds: 0 }).subtract({ days: 1 }).format('yyyy-M-D H:m:s'),
    Moment({ hour: 23, minute: 59, seconds: 59 }).subtract({ days: 1 }).format('yyyy-M-D H:m:s'),
  ],
  nearly3D: [
    Moment({ hour: 0, minute: 0, seconds: 0 }).subtract({ days: 3 }).format('yyyy-M-D H:m:s'),
    Moment({ hour: 23, minute: 59, seconds: 59 }).subtract({ days: 1 }).format('yyyy-M-D H:m:s'),
  ],
  nearly5D: [
    Moment({ hour: 0, minute: 0, seconds: 0 }).subtract({ days: 5 }).format('yyyy-M-D H:m:s'),
    Moment({ hour: 23, minute: 59, seconds: 59 }).subtract({ days: 1 }).format('yyyy-M-D H:m:s'),
  ],
  nearly7D: [
    Moment({ hour: 0, minute: 0, seconds: 0 }).subtract({ days: 7 }).format('yyyy-M-D H:m:s'),
    Moment({ hour: 23, minute: 59, seconds: 59 }).subtract({ days: 1 }).format('yyyy-M-D H:m:s'),
  ],
  thisMonth: [
    Moment({ hour: 0, minute: 0, seconds: 0 }).subtract({ months: 0 }).startOf('month').format('yyyy-M-D H:m:s'),
    Moment({ hour: 23, minute: 59, seconds: 59 }).subtract({ months: 0 }).endOf('month').format('yyyy-M-D H:m:s'),
  ],
  nearly1M: [
    Moment({ hour: 0, minute: 0, seconds: 0 }).subtract({ months: 1 }).startOf('month').format('yyyy-M-D H:m:s'),
    Moment({ hour: 23, minute: 59, seconds: 59 }).subtract({ months: 1 }).endOf('month').format('yyyy-M-D H:m:s'),
  ],
  nearly3M: [
    Moment({ hour: 0, minute: 0, seconds: 0 }).subtract({ months: 3 }).startOf('month').format('yyyy-M-D H:m:s'),
    Moment({ hour: 23, minute: 59, seconds: 59 }).subtract({ months: 1 }).endOf('month').format('yyyy-M-D H:m:s'),
  ],
}

let option_datetimePicker = {
  shortcuts: [
    {
      text: '今日',
      onClick(picker) { picker.$emit('pick', DEFINE_BASIC_VALUES['today']); }
    },
    {
      text: '昨日',
      onClick(picker) { picker.$emit('pick', DEFINE_BASIC_VALUES['yesterday']); }
    },
    {
      text: '近三日',
      onClick(picker) { picker.$emit('pick', DEFINE_BASIC_VALUES['nearly3D']); }
    },
    {
      text: '近五日',
      onClick(picker) { picker.$emit('pick', DEFINE_BASIC_VALUES['nearly5D']); }
    },
    {
      text: '近七日',
      onClick(picker) { picker.$emit('pick', DEFINE_BASIC_VALUES['nearly7D']); }
    },
    {
      text: '最近一个月',
      onClick(picker) { picker.$emit('pick', DEFINE_BASIC_VALUES['nearly1M']); }
    },
    {
      text: '最近三个月',
      onClick(picker) { picker.$emit('pick', DEFINE_BASIC_VALUES['nearly3M']); }
    }
  ]
}
let option_hmsPicker = {
  start: '00:00',
  end: '23:59',
  step: '00:01',
  format: 'H:m:s'
}
let DTRange = DEFINE_BASIC_VALUES;

export {
  DTRange,
  option_datetimePicker,
  option_hmsPicker,
}

